I have been having a lot of trouble with getting my spindle running properly with the KStep. I think this is because the POT on my motor controller doesnt have a linear response. When I check RPM with a tachometer I get crazy RPM values. My RPM could be within a few hundred and it wouldnt matter - Max spindle speed is 3,300 RPM.
I am wondering if there is a way to make my own table based off of test RPM Data? To do this I have a few questions:
- What type of value is FPGA(IO_PWMS) expecting? Something between 1-100?
- Could I manually input values for FPGA(IO_PWMS) and check actual Spindle rpm?
- I have been spending a lot of time trying to figure out how the CorrectAnalog program works. I am thinking I could update the table in that file with actual Spindle RPM to get my speed in the ballpark of what my tachometer reads. Any idea if this is possible?
#define RPM_FACTOR 3300 // RPM for full duty cycle (max analog out)
// desired speed is passed in variable 1
main()
{
float speed = *(float *)&persist.UserData[1]; // value stored is actually a float
FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
SetBitDirection(44,1); // define bit as an output
FPGA(IO_PWMS_PRESCALE) = 46; // divide clock by 46 (1.4 KHz)
FPGA(IO_PWMS+1) = 1; // Enable
FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR); // Set PWM
Thanks,
Scott